if (!jsx3.lang.Class.forName("ux.cdb.admin.receiptPkg.ContractList")) {

/**
 * Define the <code>name of class</code> class.
 * This class inherit from <code>jsx3.gui.Block<code> GUI class.
 */
jsx3.Class.defineClass(
		"ux.cdb.admin.receiptPkg.ContractList",
		jsx3.gui.Block,
		null,
		function (objRoot) {

			objRoot.prototype.onAfterDeserialize = function() {
				this.blkDetailDesc = this.getDescendantOfName("blkDetailDesc");
				this.tabPaneDetail = this.getDescendantOfName("tabPaneDetail");
				this.blkDetailDesc.show();
				this.tabPaneDetail.hide();
				this.matrix = this.get("mtxContract");				
				this.curPage = ux.megatron.Main.getServer().getDynamicProperty("@cdb@apvPkg@curPage");
				this.pageSize = ux.megatron.Main.getServer().getDynamicProperty("@cdb@apvPkg@pageNum");
				this.pagebar = this.get("blkPageWheel");
                this.pagebar.initialize();
				this.pagebar.bindWithMatrix(this, this.loadPagination, this.matrix);

				this.getDescendantOfName('tabContractInfo').getContentPane().setCSSOverride("overflow-y:auto;overflow-x:auto");
				this.getDescendantOfName('tabLoanInfo').getContentPane().setCSSOverride("overflow-y:auto;overflow-x:auto");
				this.getDescendantOfName('tabAgentInfo').getContentPane().setCSSOverride("overflow-y:auto;overflow-x:auto");
				this.getDescendantOfName('tabSudentInfo').getContentPane().setCSSOverride("overflow-y:auto;overflow-x:auto");
				this.getDescendantOfName('tabAccountInfo').getContentPane().setCSSOverride("overflow-y:auto;overflow-x:auto");
				this.getDescendantOfName('tabStudyInfo').getContentPane().setCSSOverride("overflow-y:auto;overflow-x:auto");
				this.getDescendantOfName('tabJobInfo').getContentPane().setCSSOverride("overflow-y:auto;overflow-x:auto");

				ux.megatron.Main.loadUIResourceAsync(this.getDescendantOfName('tabContractInfo').getContentPane(), "ux.cdb.admin", "ux/cdb/admin/contract/ui/ContractDetail.xml", this, function(){});
				ux.megatron.Main.loadUIResourceAsync(this.getDescendantOfName('tabLoanInfo').getContentPane(), "ux.cdb.admin", "ux/cdb/admin/loan/ui/LoanManage_DebitDetailPage.xml", this, function(){});
				ux.megatron.Main.loadUIResourceAsync(this.getDescendantOfName('tabAgentInfo').getContentPane(), "ux.cdb.admin", "ux/cdb/admin/loan/ui/LoanManage_CoDebitDetailPage.xml", this, function(){});
				ux.megatron.Main.loadUIResourceAsync(this.getDescendantOfName('tabSudentInfo').getContentPane(), "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_baseinfo.xml", this, function(){});
				ux.megatron.Main.loadUIResourceAsync(this.getDescendantOfName('tabAccountInfo').getContentPane(), "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_accinfo.xml", this, function(){});
				ux.megatron.Main.loadUIResourceAsync(this.getDescendantOfName('tabStudyInfo').getContentPane(), "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_studyinfo.xml", this, function(){});
				ux.megatron.Main.loadUIResourceAsync(this.getDescendantOfName('tabJobInfo').getContentPane(), "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_careerinfo.xml", this, function(){});
			}

			objRoot.prototype.loadPagination = function(msg) {
                this.curPage = (msg && msg.currentPageNumber) ? msg.currentPageNumber : (this.curPage || 1);
                this.loadDetailData();
            };

			objRoot.prototype.onInitializeUI = function(selectedid){
				this.selectedid = selectedid;
				this.loadDetailData();
			}

			objRoot.prototype.loadDetailData = function(){
				var me = this;
				ux.megatron.util.Dwr.callDwr("UploadRetailStudentLoanContractFeedBackProvinceUCC",
					"getBatchContractParticulars",
					[this.selectedid,this.curPage,this.pageSize],
					me,me.contractCallBack,
					"UploadRetailStudentLoanContractFeedBackProvinceUCC");
			}

			objRoot.prototype.contractCallBack = function(dwrObjectList){
				if(!dwrObjectList)
					jsx3.log("call loadContractData failed......");
				this.totalRecordCount = dwrObjectList.content.page.count;
				this.totalPages = (this.totalRecordCount % this.pageSize > 0) ? (parseInt(this.totalRecordCount / this.pageSize) + 1) : (this.totalRecordCount / this.pageSize);
				if (this.totalPages == 0) this.totalPages = 1;
				this.pagebar.setValue(this.curPage,this.totalPages,this.pageSize,this.totalRecordCount); 

				var cdfDoc = ux.megatron.util.Dwr.toShallowCdf(dwrObjectList.content.data); 
				var mtxDialogContract = ux.megatron.Main.getServer().getJSXByName("mtxContract");
				mtxDialogContract.setSourceXML(cdfDoc);
				mtxDialogContract.repaint();
			}

			objRoot.prototype.onChooseContract = function(){
				if(this.blkDetailDesc.getDisplay() != jsx3.gui.Block.DISPLAYNONE){
					this.blkDetailDesc.setDisplay(jsx3.gui.Block.DISPLAYNONE,true);
					this.tabPaneDetail.setDisplay(jsx3.gui.Block.DISPLAYBLOCK,true);
				}
				this.initContractDestail();
			}

			objRoot.prototype.initContractDestail = function(){
				var me = this;
				this.getDescendantOfName('contractDetail').setWidth(1000,true);
				this.getDescendantOfName('blkLoanDetail').setWidth(800,true);
				this.getDescendantOfName('block_coDebit').setWidth(900,true);
				this.getDescendantOfName('blkDetailBaseInfo').setWidth(900,true);
				this.getDescendantOfName('blkDetailAccInfo').setWidth(600,true);
				this.getDescendantOfName('blkDetailStudyInfo').setWidth(900,true);
				this.getDescendantOfName('blkDetailCareerInfo').setWidth(900,true);

				this.appBasicInfoId = this.matrix.getSelectedNodes().get(0).getAttribute("appBasicInfoId");
				this.studentId = this.matrix.getSelectedNodes().get(0).getAttribute("studentId");
				var details = this.getDescendantOfName('contentPane').getDescendantsOfType(ux.cdb.admin.dataautomate.GenericDetail);
				for(var i=0;i<details.length;i++){
					if(i == 0){
                        var handler = function(obj) {
                            console.log(obj);
                            obj.appPayPlanList = [];
                            obj.appPayPlanList.push({distributionDate: obj.distributionDate, amt: obj.amt});
                            return obj;
                        };
						details[i].setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Contract);
						details[i].setDataEntityId(this.appBasicInfoId);
                        details[i].setProcessHandler(handler);
					}else if (i == 1 || i == 2){
						details[i].setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Loan);
						details[i].setDataEntityId(this.appBasicInfoId);
					}else{
						details[i].setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Student);
						details[i].setDataEntityId(this.studentId);
					}
					details[i].refreshData();
				}
			}

			objRoot.prototype.selectTab = function(target){
				target.select();
			}
		});
}